Page({

    data: {
        imagePath : '',
        initImage : '',
    },

    onLoad(){
        wx.getImageInfo({
            src: 'http://dev.thinkphp.com//uploads/init.jpg',
            success: (result)=>{
                console.log(result);
                this.setData({
                    initImage : result.path,
                })
            },
            fail: ()=>{},
            complete: ()=>{}
        });
    },
    uploadImage(){
        wx.chooseImage({
            count: 2,
            sizeType: 'compressed',
            sourceType: 'album',
            success: (result)=>{
                console.log(result);
                //this.imagePath = result.tempFilePaths[0];
                this.setData({
                    imagePath: result.tempFilePaths,
                });
            },
            fail: ()=>{},
            complete: ()=>{}
        });
    },
    showImage(){
        console.log(this.data.imagePath + '', this.data.initImage + '');
        wx.previewImage({
            current: '0', // 当前显示图片的http链接
            urls: [this.data.imagePath + '', this.data.initImage + ''], // 需要预览的图片http链接列表
            showmenu: true,
          })
        
    },

    saveImage(){
        wx.saveImageToPhotosAlbum({
            filePath: this.data.imagePath,
            success: (result)=>{
                console.log(result);
            },
            fail: ()=>{console.log("fail")},
            complete: ()=>{console.log("complete")}
        });
    },
})